package com.igeek.db;

import com.igeek.bean.Brand;
import com.igeek.bean.Car;
import com.igeek.bean.Cartype;
import com.igeek.bean.User;
import sun.util.resources.LocaleData;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * 唯一的数据源
 */
public class DataDB {

    private DataDB(){

    }

    private static DataDB dataDB = new DataDB();

    public static DataDB getInstance(){
        return dataDB;
    }

    //存储用户信息
    public final static List<User> users = new ArrayList<>();

    //车辆信息
    public static final List<Car> cars = new ArrayList<>();

    //车辆品牌信息
    public static final List<Brand> brands = new ArrayList<>();

    //车辆车型信息
    public static final List<Cartype> cartypes = new ArrayList<>();

    //存储当前登录用户
    public static User currentUser = null;

    //存储车辆信息


    static {
        //车辆信息
        LocalDate localDate1 = LocalDate.of(2022, 01, 11);
        LocalDate localDate2 = LocalDate.of(2018,02,22);
        LocalDate localDate3 = LocalDate.of(2021, 03, 12);
        LocalDate localDate4 = LocalDate.of(2017,04,23);
        LocalDate localDate5 = LocalDate.of(2020, 05, 13);
        LocalDate localDate6 = LocalDate.of(2016,06,24);

        Car car1 = new Car(0001,1.6,localDate1,60000,200000,"手动挡",localDate2,123,111);
        Car car2 = new Car(0002,1.5,localDate1,10000,200000,"自动挡",localDate2,124,222);
        Car car3 = new Car(0003,1.7,localDate1,160000.0,200000,"手自一体",localDate2,125,333);
        cars.add(car1);
        cars.add(car2);
        cars.add(car3);

        //用户信息
        User user1 = new User("aaa","123", 1000000);
        User user2 = new User("bbb","456", 2000000);
        user1.setPower(1);
        User user3 = new User("ccc","789", 3000000);
        users.add(user1);
        users.add(user2);
        users.add(user3);

        //车辆品牌信息
        Brand brand1 = new Brand("雪佛兰",123);
        Brand brand2 = new Brand("大众",124);
        Brand brand3 = new Brand("奔驰",125);
        brands.add(brand1);
        brands.add(brand2);
        brands.add(brand3);

        //车辆车型信息
        Cartype cartype1 = new Cartype(111, "科鲁兹", 123);
        Cartype cartype2 = new Cartype(222, "朗逸", 124);
        Cartype cartype3 = new Cartype(333, "CLS", 125);
        cartypes.add(cartype1);
        cartypes.add(cartype2);
        cartypes.add(cartype3);

        //初始化数据
    }
}
